Google Api
Seamless Google Api integrations.
Google Maps, Places, Roads, Search and Translate.
Feel free to contribute, throw questions and report issues. I usually respond fast (24-48 hours).
Do you need support for an additional .Net framework?, let me know.
New: Version 5.0.0 with Routes Api (directions and matrix), Ariel View Api and Address Validation Api.
Using the Library
The library may be consumed, either by using the individual facede implementations or by depdendency injecting the individual api's.
Each api implementation consists of a request and a response. The request has properties reflecting the parameters supported, and the response represents the object model for the returned json.
A few other noteworthy members.
var uri = request.GetUri(); // Gets the full request uri, including query parameters.
var params = request.GetQUeryStringParameters(); // Gets a list of all the added parameters.
response.RawJson // The raw json returned by Google.
response.RawQueryString // The querystring sent to Google when invoking the request.
Facade
Each api has a generic facade operation to execute the request and return the response.
The example below, simply populates a request, invokes the facade operation, and receives the response in return.
TRequest request = new TRequest();
TResponse response = await {Api}.[{SubGroup}].{Action}.QueryAsync<TRequest, TResponse>(request);
See below for a full list of supported Api's and actions.
Dependency Injection
If injecting the api's as dependencies is preffered register the services during startup, as shown below.
services
.AddGoogleApiClients();
Then, inject the individual Api's in constructors as needed
public class MyClass
{
private Api api;
public MyClass(Api api)
{
this.api = api
}
}
See below for a full list of supported Api's and actions.
Proxy
If a WebProxy
is required set the static property HttpClientFactory.Proxy
before registrering the GoogleApi dependencies or using the Facade.
Supported Api's
The following api's are supported.
Google Maps
- Directions (
nodejs.Directions
) - Distance Matrix (
nodejs.DistanceMatrix
) - Elevation (
nodejs.Elevation
) - Geocode
- Place (
nodejs.Geocode.PlaceGeocode
) - Address (
nodejs.Geocode.AddressGeocode
) - Location (reverse) (
nodejs.Geocode.LocationGeocode
) - Plus Code (
nodejs.Geocode.PlusCodeGeocode
)
- Place (
- Geolocation (
nodejs.Geolocation
) - Roads
- Nearest Roads (
nodejs.Roads.NearestRoads
) - Snap To Roads (
nodejs.Roads.SnapToRoad
) - Speed Limits (
nodejs.Roads.SpeedLimits
)
- Nearest Roads (
- Time Zone
- Street View
- Static Maps
- Routes
- RouteDirections (
nodejs.Routes.Directions
) - RouteMatrix (
nodejs.Routes.Matrix
)
- RouteDirections (
- Address Validation (
nodejs.AddressValidation
) - Aerial View (beta)
- Get Video (
nodejs.AerialView.GetVideo
) - Render Video (
nodejs.AerialView.RenderVideo
)
- Get Video (
Google Places
- Place Search
- Find (
GooglePlaces.Search.FindSearch
) - Near By (
GooglePlaces.Search.NearBySearch
) - Text (
GooglePlaces.Search.TextSearch
)
- Find (
- Place Details (
GooglePlaces.Details
) - Place Photos (
GooglePlaces.Photos
) - Place Autocomplete (
GooglePlaces.AutoComplete
) - Query Autocomplete (
GooglePlaces.QueryAutoComplete
)
Google Search
- Web (
GoogleSearch.WebSearch
) - Image (
GoogleSearch.ImageSearch
) - Video
- Channels (
GoogleSearch.VideoSearch.Channels
) - Playlists (
GoogleSearch.VideoSearch.Playlists
) - Vidoes (
GoogleSearch.VideoSearch.Vidoes
)
- Channels (
Google Translate
- Detect (
GoogleTranslate.Detect
) - Languages (
GoogleTranslate.Languages
) - Translate (
GoogleTranslate.Translate
)
Google Functions
- MergePolyLine
- EncodePolyLine
- DecodePolyLine
Running Test Suite
Running the test suite is simple.
The test project stores settings related to your Google subscription (free or paid) in application.default.json
.
Most importantly, the ApiKey
, used to identify the Google subscription.
{
"ApiKey": "",
"SearchEngineId": "",
}
More information about generating a key can be found here: https://console.developers.google.com/